<template>
  <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-size="this.pageSize"
      layout="prev, pager, next,jumper"
      :total="this.total"
    >
    </el-pagination>
  </div>
</template>
<script>
export default {
  props: ["sendTableData","sendTotal"],
  data() {
    return {
      currentpage: 1,
      total: 6,
      pageSize: 5,
      pageData: [],
    };
  },
  created() {
    this.pageData = this.sendTableData.slice(
      this.pageSize * (this.currentpage - 1),
      this.pageSize * this.currentpage
    );
    console.log(this.pageData);
    this.$emit('sendPageData', this.pageData)
    // localStorage.data = JSON.stringify(this.tabelData)
  },
  mounted(){
    this.total = this.sendTableData.length
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.currentpage = val;
      this.pageData = this.sendTableData.slice(
        this.pageSize * (this.currentpage - 1),
        this.pageSize * this.currentpage
      );
    //   console.log(this.currentpage);
    //   console.log(this.pageData);
      this.$emit('sendPageData', this.pageData)
      this.$emit('sendCurrentPage', this.currentpage)
    },
  },
  // watch:{
  //   pageData:function(){
  //     this.pageData.push(this.sendTableData.slice(this.pageSize*(this.currentpage-1),this.pageSize*(this.currentpage-1)+1))
  //   }
  // }
};
</script>
<style lang="scss">
.block {
  position: relative;
  top: -5px;
  margin-bottom: 10px;
  text-align: right;
}
</style>